// custom-tab-bar/index.js
import {createStoreBindings, storeBindingsBehavior} from 'mobx-miniprogram-bindings'
import {store} from '../store/store'
Component({
  behaviors: [storeBindingsBehavior],
  storeBindings: {
    store,
    fields: {
      sum: 'sum',
      active: 'activeTabBarIndex'
    },
    actions: {
      updateActive: 'updateActiveTabBarIndex'
    },
  },
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
  
    list: [{
      "pagePath": "/pages/home/index",
      "text": "首页",
      "iconPath": "/images/chuku.png",
      "selectedIconPath": "/images/chuku (1).png"
    },
    {
      "pagePath": "/pages/find/index",
      "text": "发现",
      "iconPath": "/images/gaojisousuo.png",
      "selectedIconPath": "/images/gaojisousuo (1).png"
    },
  {
    "pagePath": "/pages/mine/index",
    "text": "我的",
    "iconPath": "/images/Account.png",
    "selectedIconPath": "/images/Account (1).png"
  }
  ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onChange(event) {
     
     // wx.showToast({
     //   title: `点击标签 ${this.data.list[event.detail].pagePath}`,
      //  icon: 'none',
     // });
      // event.detail 的值为当前选中项的索引
      //this.setData({ active: event.detail });
      this.updateActive(event.detail)
  
      wx.switchTab({
        url: this.data.list[event.detail].pagePath,
      })
    },
  }
})
